06. String Concatenation

string concatenation

String concatenation

Strings are a collection of characters enclosed inside double or single quotes. You can use strings to represent data like sentences, names, addresses, and more. Did you know you can even add strings together? In JavaScript, this is called concatenating. Concatenating two strings together is actually pretty simple!

"Hello," + " New York City"

Returns: "Hello, New York City"

You will see other ways to concatenate and do even more with strings later in this course. But for now, practice using the addition + operator.

What is the output?

What's the result with "hello" + "world"?

SOLUTION: "helloworld"

What is the output?

What do you think will happen when you type "Hello + 5*10" into the JavaScript console?

SOLUTION: "Hello + 5*10"

What is the output?

What do you think will happen when you type "Hello" + 5*10 into the console?

SOLUTION: "Hello50"